Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP refact(table): decouple buffer from table-view by moving paging up to model #70

Merged
merged 13 commits into from
Jun 14, 2017

Conversation

ankostis
Copy link
Contributor

@ankostis ankostis commented Jun 14, 2017

I want to add a new feature that will display pandas dataframes(see #35), but I had problems factoring out a clean table model that exposes the dataframe cells. In the process I realized that the table vitables.vttables classes LeafView/LeafModel/Buffer were highly coupled, without clear responsibilities.
This PR restructures model & buffer according to these guidelines:

  • Encapsulate buffer so as to be accessed only by model by dropping or moving buffer's paging fields UP into model:
    • Move start/nrows/chunk_size attributes up, from buffer-->model.
    • Merge model.chunk_size with nrows in model - they served the same purpose
    • Move up & merge buffer.getReadParameters()-->model.loadData().
  • Minor speedups (e.g. don't fetch cell-data if not display-role).
  • Stop using np.int64 for long tables - python ints are just as fine.
  • PEP8 & moderate renaming of variables (e.g. data_set-->leaf).
  • Apply (partially ) good practices on logging- reuse module loggers on new objects , don't set log-level in code.

WIP:

  • I started gradually implementing the refactorings, hopefully separated in small chunks.
  • The move/merge of variables from buffer --> model had to be done in one commit.
  • There are some more methods to move down from model to buffer regarding total-columns.
  • What is really left is testing, ensuring plugins work correctly, and documenting the new setup in the class docstrings and possibly in the docs of the project.
  • Any help, particularly for the testing would be welcomed.

(when it is finished, the 'WIP' has to be removed from this PR's title.)

ankostis added 7 commits June 13, 2017 22:39
+ Python's ints have arbitrary digits, are not just 32bit.
+ The `buffer.start` offset was added by models/timeseries to describe
coordinates against the full table;
buffer internally was substracting it back.
+ Change reduces a bit coupling to internals of buffer (Demeter law).
+ Reading a full chunk (1000 rows) from a compressed HDF5 file would be
a waste of CPU.
+ Also decouple readability-check from chunk-size/start value
+ Speedup model by avoiding useless data-loading.
@ankostis
Copy link
Contributor Author

@uvemas I would also like to consolidate classes a bit in fewer modules:

  • put Buffer inside vttables.leaf_model module, since it is now completely encapsulated, and
  • put both LeafDelegate & ScrollBar inside vttables.leaf_view module.

It does make sense, for instance, when a logger writes a message, you probably care if it is a view or model, but not if it is a scrollbar or a delegate. Python tradition diverts from java's one class, one file to keep things terse.

Would that be ok?

ankostis added 6 commits June 14, 2017 15:27
+ Move start/nrows/chunk_size attributes up, from buffer-->model.
+ Drop or move buffer-fields, to decouple it from model & view (ie. to
facilitate replacing it with a DataFrame).
+ Move & merge buffer.getReadParameters()-->model.loadData().
+ DROP `model.chunk_size`, it is identical to `nrows`.
- Indexing errors in `buffer.getCell()` don't report `start` anymore :-(
+ Centralize error-reporting for cell indexing-errors.
+ Logging:
  + Restore start offset-logging on cell indexing errors.
  + Class-logger-->module-var, not to waste loggers with each new
object.
  + Stop specifying log-levels (must be done to all loggers).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants